package com.mk.seckill.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author hhwu
 * @Description //TODO 封装响应状态对象
 * @Date 19:51 2022/6/6
 **/
@Data// 提供类的get、set、equals、hashCode、canEqual、toString方法
@NoArgsConstructor// 无参构造器
@AllArgsConstructor// 全参构造器
public class RespBean {

	private long code;
	private String message;
	private Object obj;
	
	public static RespBean success(){
		/**
		 * @Author hhwu
		 * @Description //TODO 响应成功的返回结果
		 * @Date 19:51 2022/6/6
		 * @Param []
		 * @return com.xxxx.seckill.vo.RespBean
		 **/
		return new RespBean(RespBeanEnum.SUCCESS.getCode(),RespBeanEnum.SUCCESS.getMessage(),null);
	}
	
	public static RespBean success(Object obj){
		/**
		 * @Author hhwu
		 * @Description //TODO 响应成功的返回结果的方法重载
		 * @Date 19:51 2022/6/6
		 * @Param [obj]
		 * @return com.xxxx.seckill.vo.RespBean
		 **/
		return new RespBean(RespBeanEnum.SUCCESS.getCode(),RespBean.success().getMessage(),obj);
	}
	
	public static RespBean error(RespBeanEnum respBeanEnum){
		/**
		 * @Author hhwu
		 * @Description //TODO 响应失败的返回结果，失败的种类很多，所以传入的是RespBean对象
		 * @Date 19:52 2022/6/6
		 * @Param [respBeanEnum]
		 * @return com.xxxx.seckill.vo.RespBean
		 **/
		return new RespBean(respBeanEnum.getCode(),respBeanEnum.getMessage(),null);
	}
	
	public static RespBean error(RespBeanEnum respBeanEnum,Object obj){
		/**
		 * @Author hhwu
		 * @Description //TODO 响应失败的返回结果的方法重载
		 * @Date 19:52 2022/6/6
		 * @Param [respBeanEnum, obj]
		 * @return com.xxxx.seckill.vo.RespBean
		 **/
		return new RespBean(respBeanEnum.getCode(),respBeanEnum.getMessage(),obj);
	}

}